package com.leehongrim.platformai.modules.controller;

import com.hw.langchain.llms.ollama.Ollama;
import com.leehongrim.platformai.common.util.OllamaUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/ai")
public class OllamaController {

    /**
     * chat
     * @param question
     * @return
     */
    @GetMapping("/chat")
    public String chat(@RequestParam("question") String question){
        log.info(" String question is {}",  question);
        String answer = OllamaUtils.send(question);
        log.info(" String answer is {}",  answer);
        return answer;
    }
}
